<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>

<s:layout-render name="/frontend/layout.jsp">
    <s:layout-component name="content">
        <br/>
        <s:useActionBean beanclass="cz.muni.fi.pa165.travelagency.web.frontend.PackageTourActionBean" var="actionBean"/>
        
        <s:form beanclass="cz.muni.fi.pa165.travelagency.web.frontend.PackageTourActionBean">
        <fieldset><legend><f:message key="search.legend" /></legend>
            <s:errors/>
            <table>
                <tr>
                    <td>
                        <s:label for="pt1" name="search.destination"/>
                    </td>
                    <td>
                        <s:text id="pt1" name="search.destination"/>
                    </td>
                    <td>
                        <s:label for="pt1" name="search.maxPrice"/>
                    </td>
                    <td>
                        <s:text id="pt1" name="search.maxPrice" value="1000000"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <s:label for="pt1" name="search.dateFrom"/>
                    </td>
                    <td>
                        <s:text id="pt1" name="search.dateFrom" value="1.1.2012"/>
                    </td>
                    <td>
                        <s:label for="pt1" name="search.dateTo"/>
                    </td>
                    <td>
                        <s:text id="pt1" name="search.dateTo" value="1.1.2100"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <s:label for="pt1" name="search.numberOfPersons"/>
                    </td>
                    <td colspan="3">
                        <s:text id="pt1" name="search.numberOfPersons" value="1"/>
                    </td>
                </tr>
            </table>
            <s:submit name="search"><f:message key="search.search" /></s:submit>
        </fieldset>
        </s:form>
        
        <c:if test="${not empty actionBean.packageTours}">
            <c:forEach items="${actionBean.packageTours}" var="ptour" varStatus="loopStatus">
                <div class="package-tour-box ${loopStatus.index % 2 == 0 ? 'even' : 'odd'}">    
                    <div class="sidebar_box">

                        <div><span class="pt-label">
                                <f:message key="ptour.name"/>: </span>
                                <s:link beanclass="cz.muni.fi.pa165.travelagency.web.frontend.PackageTourActionBean" event="detail"><s:param name="package-tour.id" value="${ptour.id}"/><c:out value="${ptour.name}"/></s:link>
                            </div>
                            <div><span class="pt-label">
                                <f:message key="ptour.destination"/>: </span>
                                <c:out value="${ptour.destination}"/>
                        </div>
                        <div><span class="pt-label">
                                <f:message key="ptour.date"/>: </span>
                            <f:formatDate value="${ptour.start}" pattern="dd. MM. yyyy" /> - <f:formatDate value="${ptour.end}" pattern="dd. MM. yyyy" />
                        </div>
                        <div><span class="pt-label">
                                <f:message key="ptour.capacity"/>: </span>
                                <c:out value="${ptour.capacity}"/>
                        </div>
                        <div><span class="pt-label">
                                <f:message key="ptour.description"/>: </span>
                                <c:out value="${ptour.description}"/>
                        </div>
                        <div><span class="pt-label">
                                <f:message key="ptour.pricePerPerson"/>: </span>
                                <c:out value="${ptour.pricePerPerson}"/>
                        </div>                            
                        <div>
                            <c:choose>
                                <c:when test="${true}">
                                    <s:link beanclass="cz.muni.fi.pa165.travelagency.web.frontend.OrderActionBean" event="create"><s:param name="package-tour.id" value="${ptour.id}"/><f:message key="ptour.order"/></s:link>
                                </c:when>
                                <c:otherwise><span class="pt-label">
                                        <f:message key="ptour.full"/></span>
                                </c:otherwise>
                            </c:choose>
                        </div>

                    </div>
                </div>
            </c:forEach>
            <br><br>
        </c:if>
    </s:layout-component>
</s:layout-render>